from PyQt6.QtCore import QThread
from proglog import ProgressBarLogger
from moviepy import *
def run():
    #videos=[]
    #for video in videos:
    #    videos.append(VideoFileClip(video))

    videos=[VideoFileClip(r"C:\Users\ggcnote\Videos\1.mp4"),VideoFileClip(r"C:\Users\ggcnote\Videos\2.mp4")]
    save_path=r"C:\Users\ggcnote\Videos\3.mp4"
    final_clip=concatenate_videoclips(videos)
    my_logger = MyLogger()
    final_clip.write_videofile(save_path,audio_codec="aac",fps=30,logger=my_logger)
class MyLogger(ProgressBarLogger):
    def __init__(self):
        super().__init__()
    def callback(self, **kw):
        print(kw)
        if 'message' in kw:
            print(kw['message'])
        bars=self.state.get('bars')#条状图
        index=len(bars.values())-1#当前进度
        print(index)
        if index>-1:
            bar=list(bars.values())[index]
            progress=int(bar["index"]/bar["total"]*100)
            print(f'progress is:{progress}%')



if __name__ == '__main__':
    run()
